import time

from selenium.webdriver.common.by import By

from common.Utils import ForumDriver

class PersonalCenter:
    url=""
    driver=""

    def __init__(self):
        self.url="http://127.0.0.1:9580/index.html"
        self.driver=ForumDriver.driver
        self.driver.get(self.url)

    #个人中心页-修改信息测试
    def PersonalCenter(self):
        #首页-点击用户头像-点击个人中心
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_avatar").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_user_settings").click()
        #是否有标题“用户中心”
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div > h2")
        #是否有列表选项-我的账户
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-body > div > div > div > div.col-3.d-none.d-md-block.border-end > div > div > a")
        #是否有昵称
        self.driver.find_element(By.CSS_SELECTOR,"#settings_nickname")
        #是否有头像
        self.driver.find_element(By.CSS_SELECTOR,"#settings_avatar")
        #是否可以修改头像
        modify_pic=self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-body > div > div > div > div.col.d-flex.flex-column > div > div.row.align-items-center > div:nth-child(2) > a")
        modify_pic.send_keys("D:\\有用的文件\\pictures\\002.jpg")
        #是否可以修改昵称
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_nickname").clear()
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_nickname").send_keys("小小")

        #是否可以修改邮箱地址
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_email").clear()
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_email").send_keys("youxiang@qq.com")

        #是否可以修改电话号码
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_phoneNum").clear()
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_phoneNum").send_keys("1008688")
        #是否可以修改个人简介
        self.driver.find_element(By.CSS_SELECTOR,"#settings_textarea_remark").clear()
        self.driver.find_element(By.CSS_SELECTOR,"#settings_textarea_remark").send_keys("这是我的个人简介")

        #是否可以正常修改密码
        # 输入原密码
        self.driver.find_element(By.CSS_SELECTOR, "#settings_input_oldPassword").send_keys("1234")
        # 输入新原密码
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_newPassword").send_keys("1234")
        # 输入确认密码
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_passwordRepeat").send_keys("1234")
        # 点击提交修改
        time.sleep(5)
        self.driver.find_element(By.CSS_SELECTOR, "#settings_submit_password").click()

        ForumDriver.getScreenShot()








